<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Fixed-Point (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Fixed-Point (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Fixed-Point (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="C-Extensions.html" rel="up" title="C Extensions">
<link href="Named-Address-Spaces.html" rel="next" title="Named Address Spaces">
<link href="Hex-Floats.html" rel="prev" title="Hex Floats">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
ul.mark-bullet {list-style-type: disc}
-->
</style>


</head>

<body lang="en_US">
<div class="section-level-extent" id="Fixed_002dPoint">
<div class="nav-panel">
<p>
Next: <a href="Named-Address-Spaces.html" accesskey="n" rel="next">Named Address Spaces</a>, Previous: <a href="Hex-Floats.html" accesskey="p" rel="prev">Hex Floats</a>, Up: <a href="C-Extensions.html" accesskey="u" rel="up">Extensions to the C Language Family</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Fixed_002dPoint-Types"><span>6.16 Fixed-Point Types<a class="copiable-link" href="#Fixed_002dPoint-Types"> &para;</a></span></h3>
<a class="index-entry-id" id="index-fixed_002dpoint-types"></a>
<a class="index-entry-id" id="index-_005fFract-data-type"></a>
<a class="index-entry-id" id="index-_005fAccum-data-type"></a>
<a class="index-entry-id" id="index-_005fSat-data-type"></a>
<a class="index-entry-id" id="index-hr-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-r-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-lr-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-llr-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-uhr-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ur-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ulr-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ullr-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-hk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-k-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-lk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-llk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-uhk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-uk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ulk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ullk-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-HR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-R-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-LR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-LLR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-UHR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-UR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ULR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ULLR-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-HK-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-K-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-LK-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-LLK-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-UHK-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-UK-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ULK-fixed_002dsuffix"></a>
<a class="index-entry-id" id="index-ULLK-fixed_002dsuffix"></a>

<p>As an extension, GNU C supports fixed-point types as
defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
types in GCC will evolve as the draft technical report changes.
Calling conventions for any target might also change.  Not all targets
support fixed-point types.
</p>
<p>The fixed-point types are
<code class="code">short _Fract</code>,
<code class="code">_Fract</code>,
<code class="code">long _Fract</code>,
<code class="code">long long _Fract</code>,
<code class="code">unsigned short _Fract</code>,
<code class="code">unsigned _Fract</code>,
<code class="code">unsigned long _Fract</code>,
<code class="code">unsigned long long _Fract</code>,
<code class="code">_Sat short _Fract</code>,
<code class="code">_Sat _Fract</code>,
<code class="code">_Sat long _Fract</code>,
<code class="code">_Sat long long _Fract</code>,
<code class="code">_Sat unsigned short _Fract</code>,
<code class="code">_Sat unsigned _Fract</code>,
<code class="code">_Sat unsigned long _Fract</code>,
<code class="code">_Sat unsigned long long _Fract</code>,
<code class="code">short _Accum</code>,
<code class="code">_Accum</code>,
<code class="code">long _Accum</code>,
<code class="code">long long _Accum</code>,
<code class="code">unsigned short _Accum</code>,
<code class="code">unsigned _Accum</code>,
<code class="code">unsigned long _Accum</code>,
<code class="code">unsigned long long _Accum</code>,
<code class="code">_Sat short _Accum</code>,
<code class="code">_Sat _Accum</code>,
<code class="code">_Sat long _Accum</code>,
<code class="code">_Sat long long _Accum</code>,
<code class="code">_Sat unsigned short _Accum</code>,
<code class="code">_Sat unsigned _Accum</code>,
<code class="code">_Sat unsigned long _Accum</code>,
<code class="code">_Sat unsigned long long _Accum</code>.
</p>
<p>Fixed-point data values contain fractional and optional integral parts.
The format of fixed-point data varies and depends on the target machine.
</p>
<p>Support for fixed-point types includes:
</p><ul class="itemize mark-bullet">
<li>prefix and postfix increment and decrement operators (<code class="code">++</code>, <code class="code">--</code>)
</li><li>unary arithmetic operators (<code class="code">+</code>, <code class="code">-</code>, <code class="code">!</code>)
</li><li>binary arithmetic operators (<code class="code">+</code>, <code class="code">-</code>, <code class="code">*</code>, <code class="code">/</code>)
</li><li>binary shift operators (<code class="code">&lt;&lt;</code>, <code class="code">&gt;&gt;</code>)
</li><li>relational operators (<code class="code">&lt;</code>, <code class="code">&lt;=</code>, <code class="code">&gt;=</code>, <code class="code">&gt;</code>)
</li><li>equality operators (<code class="code">==</code>, <code class="code">!=</code>)
</li><li>assignment operators (<code class="code">+=</code>, <code class="code">-=</code>, <code class="code">*=</code>, <code class="code">/=</code>,
<code class="code">&lt;&lt;=</code>, <code class="code">&gt;&gt;=</code>)
</li><li>conversions to and from integer, floating-point, or fixed-point types
</li></ul>

<p>Use a suffix in a fixed-point literal constant:
</p><ul class="itemize mark-bullet">
<li>&lsquo;<samp class="samp">hr</samp>&rsquo; or &lsquo;<samp class="samp">HR</samp>&rsquo; for <code class="code">short _Fract</code> and
<code class="code">_Sat short _Fract</code>
</li><li>&lsquo;<samp class="samp">r</samp>&rsquo; or &lsquo;<samp class="samp">R</samp>&rsquo; for <code class="code">_Fract</code> and <code class="code">_Sat _Fract</code>
</li><li>&lsquo;<samp class="samp">lr</samp>&rsquo; or &lsquo;<samp class="samp">LR</samp>&rsquo; for <code class="code">long _Fract</code> and
<code class="code">_Sat long _Fract</code>
</li><li>&lsquo;<samp class="samp">llr</samp>&rsquo; or &lsquo;<samp class="samp">LLR</samp>&rsquo; for <code class="code">long long _Fract</code> and
<code class="code">_Sat long long _Fract</code>
</li><li>&lsquo;<samp class="samp">uhr</samp>&rsquo; or &lsquo;<samp class="samp">UHR</samp>&rsquo; for <code class="code">unsigned short _Fract</code> and
<code class="code">_Sat unsigned short _Fract</code>
</li><li>&lsquo;<samp class="samp">ur</samp>&rsquo; or &lsquo;<samp class="samp">UR</samp>&rsquo; for <code class="code">unsigned _Fract</code> and
<code class="code">_Sat unsigned _Fract</code>
</li><li>&lsquo;<samp class="samp">ulr</samp>&rsquo; or &lsquo;<samp class="samp">ULR</samp>&rsquo; for <code class="code">unsigned long _Fract</code> and
<code class="code">_Sat unsigned long _Fract</code>
</li><li>&lsquo;<samp class="samp">ullr</samp>&rsquo; or &lsquo;<samp class="samp">ULLR</samp>&rsquo; for <code class="code">unsigned long long _Fract</code>
and <code class="code">_Sat unsigned long long _Fract</code>
</li><li>&lsquo;<samp class="samp">hk</samp>&rsquo; or &lsquo;<samp class="samp">HK</samp>&rsquo; for <code class="code">short _Accum</code> and
<code class="code">_Sat short _Accum</code>
</li><li>&lsquo;<samp class="samp">k</samp>&rsquo; or &lsquo;<samp class="samp">K</samp>&rsquo; for <code class="code">_Accum</code> and <code class="code">_Sat _Accum</code>
</li><li>&lsquo;<samp class="samp">lk</samp>&rsquo; or &lsquo;<samp class="samp">LK</samp>&rsquo; for <code class="code">long _Accum</code> and
<code class="code">_Sat long _Accum</code>
</li><li>&lsquo;<samp class="samp">llk</samp>&rsquo; or &lsquo;<samp class="samp">LLK</samp>&rsquo; for <code class="code">long long _Accum</code> and
<code class="code">_Sat long long _Accum</code>
</li><li>&lsquo;<samp class="samp">uhk</samp>&rsquo; or &lsquo;<samp class="samp">UHK</samp>&rsquo; for <code class="code">unsigned short _Accum</code> and
<code class="code">_Sat unsigned short _Accum</code>
</li><li>&lsquo;<samp class="samp">uk</samp>&rsquo; or &lsquo;<samp class="samp">UK</samp>&rsquo; for <code class="code">unsigned _Accum</code> and
<code class="code">_Sat unsigned _Accum</code>
</li><li>&lsquo;<samp class="samp">ulk</samp>&rsquo; or &lsquo;<samp class="samp">ULK</samp>&rsquo; for <code class="code">unsigned long _Accum</code> and
<code class="code">_Sat unsigned long _Accum</code>
</li><li>&lsquo;<samp class="samp">ullk</samp>&rsquo; or &lsquo;<samp class="samp">ULLK</samp>&rsquo; for <code class="code">unsigned long long _Accum</code>
and <code class="code">_Sat unsigned long long _Accum</code>
</li></ul>

<p>GCC support of fixed-point types as specified by the draft technical report
is incomplete:
</p>
<ul class="itemize mark-bullet">
<li>Pragmas to control overflow and rounding behaviors are not implemented.
</li></ul>

<p>Fixed-point types are supported by the DWARF debug information format.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Named-Address-Spaces.html">Named Address Spaces</a>, Previous: <a href="Hex-Floats.html">Hex Floats</a>, Up: <a href="C-Extensions.html">Extensions to the C Language Family</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
